<template>
  <div class="tu">
    <!-- <div class="outer_label">
      <img class="inner_label login_logo" src="../../assets/logo.png">
    </div> -->
  
    <div class="login_form">
      <p class="title">登录</p>
      <input type="text"  class="qxs-ic_user qxs-icon"  placeholder="用户名" v-model="userName">
      <input type="password"  class="qxs-ic_password qxs-icon"   auto-complete="off" placeholder="密码" v-model="password">
      <!--<button class="login_btn el-button el-button&#45;&#45;primary is-round" type="primary" round>登录</button>-->
      <el-button class="login_btn" @click="denglu" @click.native="login" type="primary" round :loading="isBtnLoading">登录</el-button>
      <div style="margin-top: 10px">
       <span style="float: inherit;color: yellow">忘记密码？</span>
      </div>
    </div>
  </div>
</template>

<script>
import md5 from 'js-md5';
export default {
    data() {
      return {
        userName: '',
        password: '',
        isBtnLoading: false
      }
    },
    created () {
      if(JSON.parse( localStorage.getItem('user')) && JSON.parse( localStorage.getItem('user')).userName){
        this.userName = JSON.parse( localStorage.getItem('user')).userName;
        this.password = JSON.parse( localStorage.getItem('user')).password;
      }
    },
    computed: {
      btnText() {
        if (this.isBtnLoading) return '登录中...';
        return '登录';
      }
    },
    methods: {
      login() {
        if (!this.userName) {
          this.$message.error('请输入用户名');
          return;
        }
        if (!this.password) {
          this.$message.error('请输入密码');
          return;
        }
    
      },
      denglu(){
         this.axios.post("/hr/hrlogin", {
        zhanghao:this. userName,
        password:md5(this.password)      
      }).then(res => {
        console.log(res);
        alert(res.data.msg)
        if(res.data.msg=="登录成功"){
           this.$router.push({
        path: "/zhuye"
      });
        }
        var zhang = JSON.parse(res.config.data)
        localStorage.setItem("111",zhang.zhanghao)
      });
      }
    }
  }
</script>

<style>
.title { 
  font-size: 26px;
  line-height: 50px;
  font-weight: bold;
  margin: 0px;
  text-align: center;
}
  .login_form {
  height: 100%;
    padding-top: 10%;
    padding-left: 10%;
    padding-right: 10%;
    
  }
  .qxs-icon{
    width: 30%;
    display: block;
    float: inherit;
    margin: 5px auto!important;
  
  }
  .qxs-ic_user {
    background: url("../assets/user.png") no-repeat;
    background-size: 20px 20px;
    background-position: 3%;
  }
  .qxs-ic_password {
   background: url("../assets/pas.png") no-repeat;
    background-size: 20px 20px;
    background-position: 3%;
    margin-bottom: 20px;
  }
  .login_btn {
    width: 40%;
    font-size: 16px;
    background: -webkit-linear-gradient(left, #000099, #2154FA); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(right, #000099, #2154FA); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(right, #000099, #2154FA); /* Firefox 3.6 - 15 */
    background: linear-gradient(to right, #000099 , #2154FA); /* 标准的语法 */
    filter: brightness(1.4);
  }
  .tu{
    width: 100%;
    height: 100%;
   background-image: url("../assets/bgtu.png");
  }
</style>
